package com.dgut.autoconfig;

import ch.qos.logback.classic.Logger;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
/*
    监听器
 */
@Component
@Slf4j
public class MailSendListener implements ApplicationListener<MailSendEvent> {
    private static final Logger log= (Logger) LoggerFactory.getLogger(MailSendEvent.class);
@Async
@EventListener(classes ={MailSendEvent.class})
    public void onApplicationEvent(MailSendEvent event){
        log.info("MailSendEvent事件启动了...");
        log.info("向{}发送邮件,邮件内容为:{}",event.getTo(),event.getMessage());
    }
}
